
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
postcss-normalize-charset
Advanced tools
The postcss-normalize-charset npm package is a PostCSS plugin that ensures that a single @charset rule is present at the top of your CSS files. It can remove unnecessary @charset rules and can add one if not present when a non-ASCII character is found in the file. This helps in maintaining the proper character encoding in your CSS, which is important for the correct rendering of text in web pages.
Adding @charset rule
This feature automatically adds an @charset rule to the CSS if the file contains non-ASCII characters and no @charset rule is present.
const postcss = require('postcss');
const normalizeCharset = require('postcss-normalize-charset');
postcss([normalizeCharset()])
.process('a { content: "\2014" }', { from: undefined })
.then(result => {
console.log(result.css);
// Output: '@charset "utf-8";\na { content: "\2014" }'
});
Removing unnecessary @charset rules
This feature removes duplicate or unnecessary @charset rules, ensuring that only one is present at the top of the CSS file.
const postcss = require('postcss');
const normalizeCharset = require('postcss-normalize-charset');
postcss([normalizeCharset()])
.process('@charset "utf-8";\n@charset "utf-8";\na { color: black; }', { from: undefined })
.then(result => {
console.log(result.css);
// Output: '@charset "utf-8";\na { color: black; }'
});
This package is similar in that it is also a PostCSS plugin aimed at CSS optimization. It minifies font declarations by removing duplicates and optimizing font-family names, but it does not handle charset normalization.
cssnano is a modular CSS minifier that includes various PostCSS plugins, including one for charset normalization. It provides a broader range of optimizations compared to postcss-normalize-charset, which focuses solely on charset normalization.
This PostCSS plugin removes comments from your CSS files. While it does not directly relate to charset normalization, it is another tool in the realm of CSS optimization that can be used alongside postcss-normalize-charset to reduce file size and improve loading times.
Add necessary or remove extra charset with PostCSS
a{
content: "©";
}
@charset "utf-8";
a{
content: "©";
}
Type: boolean
Default: true
Pass false
to stop the module from adding a @charset
declaration if it was
missing from the file (and the file contained non-ascii characters).
See the PostCSS documentation for examples for your environment.
See CONTRIBUTORS.md.
MIT © Bogdan Chadkin
FAQs
Add necessary or remove extra charset with PostCSS
The npm package postcss-normalize-charset receives a total of 10,923,170 weekly downloads. As such, postcss-normalize-charset popularity was classified as popular.
We found that postcss-normalize-charset demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.